package com.nbsaas.boot.cms.data.entity;

import com.nbsaas.boot.code.annotation.*;
import com.nbsaas.boot.jpa.data.entity.AbstractEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import lombok.Data;
import org.hibernate.annotations.Comment;

@CreateByUser
@ComposeView
@Data
@FormAnnotation(title = "内容块", model = "内容块")
@Entity
@Table(name = "bs_content_block")
@Comment("内容块表")
public class ContentBlock extends AbstractEntity {

    @Comment("内容块名称")
    @SearchItem(name = "name", key = "name", label = "内容块名称")
    @FormField(title = "内容块名称", sortNum = "1", grid = true, required = true)
    @Column(length = 100, nullable = false)
    private String name;

    @Comment("内容块标识")
    @FormField(title = "内容块标识", sortNum = "2", grid = true, required = true)
    @Column(length = 100, nullable = false, unique = true)
    private String code;

    @Comment("内容块内容")
    @FormField(title = "内容块内容", sortNum = "3", type = InputType.richText, col = 23)
    @Column(columnDefinition = "TEXT")
    private String content;

    @Comment("内容块类型")
    @FormField(title = "内容块类型", sortNum = "4", grid = true, type = InputType.select)
    @Column(length = 20)
    private String blockType; // HTML-HTML内容, TEMPLATE-模板内容, COMPONENT-组件内容

    @Comment("内容块描述")
    @FormField(title = "内容块描述", sortNum = "5", type = InputType.textarea)
    @Column(length = 500)
    private String description;

    @Comment("排序")
    @FormField(title = "排序", sortNum = "6", grid = true, type = InputType.el_input_number, sort = true)
    private Integer sort;

    @Comment("是否启用")
    @FormField(title = "是否启用", sortNum = "7", grid = true, type = InputType.select)
    private Boolean enabled;

    @Comment("缓存时间(秒)")
    @FormField(title = "缓存时间(秒)", sortNum = "8", grid = true, type = InputType.el_input_number)
    private Integer cacheTime;

    @Comment("CSS类名")
    @FormField(title = "CSS类名", sortNum = "9")
    @Column(length = 200)
    private String cssClass;

    @Comment("自定义CSS")
    @FormField(title = "自定义CSS", sortNum = "10", type = InputType.textarea)
    @Column(columnDefinition = "TEXT")
    private String customCss;

    @Comment("自定义JS")
    @FormField(title = "自定义JS", sortNum = "11", type = InputType.textarea)
    @Column(columnDefinition = "TEXT")
    private String customJs;

    @Comment("参数配置")
    @FormField(title = "参数配置", sortNum = "12", type = InputType.textarea)
    @Column(columnDefinition = "TEXT")
    private String parameters;

    @Comment("使用次数")
    @FormField(title = "使用次数", sortNum = "13", grid = true, type = InputType.el_input_number, sort = true)
    private Integer useCount;
} 